<%@ page language='java' contentType='text/html; charset=UTF-8'
    pageEncoding='UTF-8'%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<%
    String path = request.getContextPath();
%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>用户列表</title>
<script src="//code.jquery.com/jquery-1.11.0.min.js"></script>
<script>
function del(id){
	$.ajax({
		type:"delete",
		url:"<%=path %>/user/" + id,
		async:false,
		dataType:"json",
		success:function(data){
			if(data) {
				window.location.href="<%=path %>/user";
			}
		}
		
	});
} 

function add() {
	window.location.href="<%=path %>/user/new";
}
</script>
</head>
<body>
<table>
	<tr>
		<td width="50px">ID</td><td width="100px">姓名</td><td width="200px">邮箱</td>
		<td width="50px">编辑</td><td width="50px">删除</td>
	</tr>
	<c:forEach items="${list}" var="u">
		<tr>
			<td width="50px">${u.userId}</td>
			<td width="100px">${u.userName}</td>
			<td width="200px">${u.userEmail}</td>
			<td width="50px"><a href="<%=path %>/user/${u.userId}/edit">编辑</a></td>
			<td width="50px"><a href="javascript:void(0);" onclick="del('${u.userId}')">删除</a></td>
		</tr>
	</c:forEach>
</table>

<input type="button" value="添加" onclick="add()"/>
</body>
</html>